package com.liuwa.openapi.controller;

import com.liuwa.common.core.domain.Result;
import com.liuwa.common.utils.bean.BeanUtils;
import com.liuwa.knowledge.domain.Publisher;
import com.liuwa.knowledge.query.PublisherQuery;
import com.liuwa.knowledge.service.PublisherService;
import com.liuwa.openapi.common.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 出版社Controller
 * 
 * @author liuwa
 * @date 2025-03-31 22:30:11
 */
@RestController
@Api(value = "出版社")
@RequestMapping("/openapi/publishers")
public class OpenapiPublisherController extends BaseController{

    @Autowired
    private PublisherService publisherService;

    /**
     * 查询出版社列表
     */
    @ApiOperation("查询出版社列表")
    @GetMapping
    public Result.ItemsVo list(PublisherQuery query)
    {
        Publisher condition = new Publisher();
        BeanUtils.copyBeanNotNull2Bean(query, condition);
        List<Publisher> list = publisherService.findList(condition);
        return Result.items(list);
    }


    /**
     * 获取出版社详细信息
     */
    @ApiOperation("获取出版社详细信息")
    @GetMapping(value = "/{id}")
    public Publisher get(@PathVariable("id") String id)
    {
        return publisherService.get(id);
    }


}
